<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
	$targ_w = $targ_h = 150;
	$jpeg_quality = 90;

	$src = 'banner/Saree.jpg';
	$img_r = imagecreatefromjpeg($src);
	$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

	imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
	$targ_w,$targ_h,$_POST['w'],$_POST['h']);

	header('Content-type: image/jpeg');
	imagejpeg($dst_r,null,$jpeg_quality);

	exit;
}
?>
<!DOCTYPE HTML>
<html>
  <head>
    <title>Kidswear</title>
        <link rel="SHORTCUT ICON" href="img/favicon.ico" />	
        <script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>     
				<link rel="stylesheet" href="css/style.css" />
        <link rel="stylesheet" href="css/grid-12.css" />
				<script src="jquery/jquery.min.js"></script>
				<script src="jquery/jquery.Jcrop.js"></script>
				<link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" />
				<link rel="stylesheet" href="demo_files/demos.css" type="text/css" />
        <meta name="description" content="clothing" />
				<meta name="keywords" content="kunuki, kidswerar, girlswear, womenswear, accessories, assamese, guwahati clothings" />
				<meta name="author" content="Tigmaminds" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
				<script type="text/javascript" src="script/product_registration.js"></script>  
        <script type="text/javascript" language="javascript">
			$(function(){
				$('#cropbox').Jcrop({
					aspectRatio: .75,
					onSelect: updateCoords
				});
			});
			function updateCoords(c)
			{
				$('#x').val(c.x);
				$('#y').val(c.y);
				$('#w').val(c.w);
				$('#h').val(c.h);
			};
			function checkCoords()
			{
				if (parseInt($('#w').val())) return true;
				alert('Please select a crop region then press submit.');
				return false;
			};       
				</script>
  </head>
  <body>
    <div id="container" class="container_12">
    
    <?php require("php/header.php"); ?>
      <div id="line" class="grid_12"></div>
      <div id="" class="grid_6">
			<form action="product_registration.php" method="post" onsubmit="return checkCoords();">
				<input type="hidden" id="x" name="x" />
				<input type="hidden" id="y" name="y" />
				<input type="hidden" id="w" name="w" />
				<input type="hidden" id="h" name="h" />
				<input type="submit" value="Crop Image" />
			</form>

        <?php include("html/product_registration_form.html"); ?>
      </div>
			<?php require("php/footer.php"); ?>
    </div>
  </body>
</html>
